# -*- coding: utf-8 -*-
"""
created on 2017/12/11 13:59

@author: didichen
"""


def diag_2_sym(strng):
    strng_list = strng.split('\n')
    n = len(strng_list)
    word_list = []
    for i in range(n - 1, -1, -1):
        char_list = [strng_list[j][i] for j in range(n - 1, -1, -1)]
        word_list.append(''.join(char_list))
    return '\n'.join(word_list)


def rot_90_counter(strng):
    # your code
    strng_list = strng.split('\n')
    n = len(strng_list)
    word_list = []
    for i in range(n - 1, -1, -1):
        char_list = [strng_list[j][i] for j in range(0, n, 1)]
        word_list.append(''.join(char_list))
    return '\n'.join(word_list)


def selfie_diag2_counterclock(strng):
    # your code
    strng_list = strng.split('\n')
    n = len(strng_list)
    word_list = []
    for i in range(0, n, 1):
        char_1ist_1 = strng_list[i]
        char_1ist_2= ''.join([strng_list[j][n-1-i] for j in range(n-1, -1, -1)])
        char_1ist_3 = ''.join([strng_list[j][n-1-i] for j in range(0, n, 1)])
        word_list.append('|'.join([char_1ist_1,char_1ist_2,char_1ist_3]))
    return '\n'.join(word_list)


def oper(fct, s):
    return fct(s)


if __name__ == '__main__':
    s = "abcd\nefgh\nijkl\nmnop"
    # print(oper(rot_90_counter, "EcGcXJ\naaygcA\nNgIshN\nyOrCZE\neBEqpm\nNkxCgw"))
    rot_90_counter = lambda s: list(zip(*s))[::-1]
    diag_2_sym = lambda s: list(zip(*s[::-1]))[::-1]
    selfie_diag2_counterclock = lambda s: (tuple(l) + ('|',) + m + ('|',) + r
                                           for l, m, r in zip(s, diag_2_sym(s), rot_90_counter(s)))
    oper = lambda func, s: '\n'.join(map(''.join, func(s.split('\n'))))
    print(oper(rot_90_counter,"EcGcXJ\naaygcA\nNgIshN\nyOrCZE\neBEqpm\nNkxCgw"))
# JANEmw\nXchZpg\ncgsCqC\nGyIrEx\ncagOBk\nEaNyeN